Alias functions
Alias functions allow to extend plugin repositories without recompiling them. The functions are dynamic C# language functions that are injected at beginning of Insights Definitions processing by Triggering Engine.
Implementation
An example alias function might look like the following:
public static double AverageCountMonthly(
this Meniga.InsightsFactory.DigitalBankingContracts.Transactions.ITransactionsRepository @this,
Meniga.InsightsFactory.DigitalBankingContracts.Transactions.Filter.TransactionsFilter filter)
{
var filteredTransactions = filter.Apply(@this.Transactions)
.GroupBy(x => new { x.TransactionDate.Year, x.TransactionDate.Month })
.Select(monthGroup => monthGroup.Count())
.ToList();
return filteredTransactions.Any() ? filteredTransactions.Average() : 0;
}
Alias functions with the appropriate metadata should be added to the Insights Factory database in the table insghtsfactory.alias_function_metadata
. Insight Factory release package comes with a tool that helps to generate metadata for alias functions. This tool prepares all the necessary database migration to generate SQL files to update the metadata table.
Successfully added alias function will be available by Bank Admin API under endpoint GET /admin/v1/insights/metadata/functions
and will be visible in the Triggering Engine Insights Definitions evaluator.
Modifying Alias functions directly in the database requires cache invalidation in order for the changes to be reflected in Triggering Engine. This can be done through either:
- the dedicated endpoint
POST /admin/v1/dynamics/cache/invalidate
which will clear cache in Triggering Engine and cause re-compilation of Insight Definition conditions (leading to a slight increase in memory consumption). - restarting each Triggering Engine node